<?php
if (!defined('IN_CONTEXT')) die('access violation error!');

if($isEmpty)
{
	echo "Data is empty.";
}
else
{
?>
<script type="text/javascript" src="./script/js/jquery.ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$( "#tpl_start_time" ).datepicker({ dateFormat: 'yy-mm-dd' });
	$( "#tpl_end_time" ).datepicker({ dateFormat: 'yy-mm-dd' });
	
	$("#select_result").click(function(){
		var tpl_category_id = $('#tpl_category_id').val();
		var tpl_designer_id = $("#tpl_designer_id").val();
		var tpl_tester_id = $("#tpl_tester_id").val();
		var tpl_status = $("#tpl_status").val();
		var tpl_start_time = $("#tpl_start_time").val();
		var tpl_end_time = $("#tpl_end_time").val();

		$.ajax({
			type: "GET",
			url: "index.php?_m=statistics&_a=doSearchJob",
			data: "tpl_category_id="+tpl_category_id+"&tpl_designer_id="+tpl_designer_id+"&tpl_tester_id="+tpl_tester_id+"&tpl_status="+tpl_status+"&tpl_start_time="+tpl_start_time+"&tpl_end_time="+tpl_end_time,
			beforeSend:function(){
				$("#stat").empty().show().append('Loading...');	
				$('.ajaxContent').remove();
			},
			success:function(response){
				$("#stat").hide();
				$('#result').append(response);
				var num = $('.ajaxContent').attr('num');
				$(".record").empty().append(num);
			},
			error:function(response){
				$("#stat").hide();
				alert("Search failed.");
			}
		});
	});
	
});
</script>
<div id="stat" style="display:none;margin-top:20px;"></div>
<table style="margin-top:20px;position:relative;right:7px;" width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#4c4c4c">
<tr><td colspan="6" class="table_title">搜索条件</td></tr>
<tr>
	<td width="16%">模板行业</td>
	<td width="18%">
		<select name="tpl_category_id" id="tpl_category_id">
			<option value="0">查询全部</option>
			<?php
			foreach($template_categories as $v)
			{
//				echo "<option value='{$v['tpl_category_id']}'>{$v['tpl_category_name']}</option>";
				if($v['tpl_super_id'] != 0)
				{
					$category_tmp[$v['tpl_super_id']][] = $v; 
				}
			}
			
			foreach($template_categories as $v)
			{
				if(array_key_exists($v['tpl_category_id'],$category_tmp))
				{
					echo "<optgroup label='{$v['tpl_category_name']}'>";
					foreach($category_tmp[$v['tpl_category_id']] as $v1)
					{
						echo "<option value='{$v1['tpl_category_id']}'>{$v1['tpl_category_name']}</option>";
					}
					echo "</optgroup>";
				}
				elseif($v['tpl_super_id'] == 0)
				{
					$str_tmp .= "<option value='{$v['tpl_category_id']}'>{$v['tpl_category_name']}</option>";
				}		
			}
			//echo $str_tmp."<option value='0'>查询全部</option>";
			?>
		</select>
	</td>
	<td width="16%">设计人员</td>
	<td width="18%">
		<select name="tpl_designer_id" id="tpl_designer_id">
		<?php 
		if(empty($designers)) $designers = array();
		echo "<option value='0'>全部</option>";
		foreach($designers as $k => $v)
		{
			echo "<option value='{$v['u_id']}'>{$v['u_name']}</option>";	
		}
		?>
		</select>
	</td>
	<td width="16%">测试人员</td>
	<td width="16%">
		<select name="tpl_tester_id" id="tpl_tester_id">
		<?php
		if(empty($testers)) $testers = array();
		echo "<option value='0'>全部</option>";
		foreach($testers as $k => $v)
		{
			echo "<option value='{$v['u_id']}'>{$v['u_name']}</option>";	
		}
		?>
		</select>
	</td>
</tr>
<tr>
	<td width="16%">模板状态</td>
	<td width="16%">
		<select name="tpl_status" id="tpl_status">
		<?php 
		if(empty($template_status)) $template_status = array();
		echo "<option value='0'>全部</option>";
		foreach($template_status as $k => $v)
		{
			echo "<option value='{$v['s_id']}'>{$v['s_alias']}</option>";
		}
		?>
		</select>
	</td>
	<td width="18%">开始制作时间</td>
	<td width="16%"><input type="text" id="tpl_start_time" size="10"></td>
	<td width="18%">完成发布时间</td>
	<td width="16%"><input type="text" id="tpl_end_time" size="10"></td>
</tr>
<tr>
	<td colspan="6" style="text-align:left;"><input id="select_result" type="button" value="查询"/></td>
</tr>
</table>
<table id="result" style="position:relative;right:7px;" width="100%" border="0" cellpadding="2" cellspacing="0" bordercolor="#4c4c4c">
<tr><td style='position:relative;' class="table_title" colspan="6">查询结果 <span style="position:absolute;right:30px;"><span class="record">0</span>条记录</span></td></tr>
<tr>
	<td>模板名</td>
	<td>三级域名</td>
	<td>模板状态</td>
	<td>模板行业</td>
	<td>设计人员</td>
	<td>测试人员</td>
</tr>
</table>
<?php
}
?>